package com.sc.file;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        FileDirCheck fileDirCheck = new FileDirCheck();
        String path = "/1/360";
        List<String> list = fileDirCheck.traverseFolder1("/Volumes/NESO"+path);
//        ArrayList<String> stringList = getSingle(list);
        File file = new File("/Users/fzzz/work"+path);
        try {
            FileWriter fw = new FileWriter(file);
            PrintWriter pw = new PrintWriter(fw);
//            if (stringList != null && stringList.size() > 0) {
//                for (String s : stringList) {
//                    pw.append(s);
//                    pw.println();
//                }
//            }
            if (list != null && list.size() > 0) {
                for (String s : list) {
                    pw.append(s);
                    pw.println();
                }
            }

            fw.close();
            pw.close();
            list.clear();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static ArrayList<String> getSingle(List<String> list) {
        ArrayList<String> newList = new ArrayList();
        String result = "";
        for (String s1 : list) {
            String[] strs1 = s1.split("-");
            for (String s2 : list) {
                String[] strs2 = s2.split("-");
                if (!s1.equals(s2) && strs1[0].equals(strs2[0])) {
                    result = strs1[1] += "===" + strs2[1];
                }
            }
            if (!result.contains(strs1[1])) {
                newList.add(result);
                result = "";
            }
        }
        return newList;//返回重复元素的集合
    }
}
